<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>addTemplateDir()</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="api.functions.html" title="Chapter 14. Smarty Class Methods">
<link rel="prev" href="api.add.plugins.dir.html" title="addPluginsDir()">
<link rel="next" href="api.append.html" title="append()">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">addTemplateDir()</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="api.add.plugins.dir.html">Prev</a> </td>
<th width="60%" align="center">Chapter 14. Smarty Class Methods</th>
<td width="20%" align="right"> <a accesskey="n" href="api.append.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="refentry" title="addTemplateDir()">
<a name="api.add.template.dir"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>addTemplateDir() — add a directory to the list of directories where templates are stored</p>
</div>
<div class="refsect1" title="Description">
<a name="id426147"></a><h2>Description</h2>
<code class="methodsynopsis"><span class="type">Smarty </span><span class="methodname">addTemplateDir</span>(<span class="methodparam"><span class="type">string|array </span><span class="parameter">template_dir</span></span>,<br>                      <span class="methodparam"><span class="type">string </span><span class="parameter">key</span></span>);</code><div class="example">
<a name="id426692"></a><p class="title"><b>Example 14.3. addTemplateDir()</b></p>
<div class="example-contents"><pre class="programlisting">

&lt;?php

// add directory where templates are stored
$smarty-&gt;addTemplateDir('./templates_1');

// add directory where templates are stored and specify array-key
$smarty-&gt;addTemplateDir('./templates_1', 'one');

// add multiple directories where templates are stored and specify array-keys
$smarty-&gt;addTemplateDir(array(
    'two' =&gt; './templates_2',
    'three' =&gt; './templates_3',
));

// view the template dir chain
var_dump($smarty-&gt;getTemplateDir());

// chaining of method calls
$smarty-&gt;setTemplateDir('./templates')
       -&gt;addTemplateDir('./templates_1', 'one')
       -&gt;addTemplateDir('./templates_2', 'two');

?&gt;

   </pre></div>
</div>
<br class="example-break"><p>
   See also
   <a class="link" href="api.get.template.dir.html" title="getTemplateDir()"><code class="varname">getTemplateDir()</code></a>,
   <a class="link" href="api.set.template.dir.html" title="setTemplateDir()"><code class="varname">setTemplateDir()</code></a> and
   <a class="link" href="variable.template.dir.html" title="$template_dir"><em class="parameter"><code>$template_dir</code></em></a>.
  </p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="api.add.plugins.dir.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="api.functions.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="api.append.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">addPluginsDir() </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> append()</td>
</tr>
</table>
</div>
</body>
</html>
